package com.fhz.kotlinstest.paging

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.fhz.kotlinstest.ApiService
import com.fhz.kotlinstest.Banner

class ExamplePagingSource(
    val backend: ApiService,
    val query: String
) : PagingSource<Int, Banner>() {

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Banner> {
//        try {
//            // Start refresh at page 1 if undefined.
//            val nextPageNumber = params.key ?: 1
////            val response = backend.searchUsers(query, nextPageNumber)
//            val response = backend.getBanner(query, nextPageNumber)
//            return LoadResult.Page(
//                data = response.users,
//                prevKey = null, // Only paging forward.
//                nextKey = response.nextPageNumber
//            )
//        } catch (e: Exception) {
//            // Handle errors in this block and return LoadResult.Error for
//            // expected errors (such as a network failure).
//        }
        TODO()
    }

    override fun getRefreshKey(state: PagingState<Int, Banner>): Int? {
        TODO()
    }


}